<%-- 
    Document   : listMessage
    Created on : Jun 28, 2013, 7:53:46 PM
    Author     : Anna SAELEE
--%>

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link type="text/css" rel="stylesheet" href="style.css"/>
        <title>Liste des demandes de services</title>
    </head>
    <%  Connection conn;
        Statement stmt;
        ResultSet rs;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dormitorymanagement", "root", "root");
            stmt = conn.createStatement();%>
    <body>
        <div class="wrapper">
            <div class="header"></div>
            <div class="navigator"> <a href="#">MENU</a> > <a href="#">SUBMENU</a> 30*1000 </div>
            <div class="workspace">
                <%@include file="connect.jsp" %>
                <div class="workspace2">
                    <% if (session.getAttribute("username") == null) {%>
                    Vous n'avez pas de droit pour voir des information de cette page!
                    <% } else {%>
                    <h3>Liste des demandes de services</h3><br/>
                    <div class="workspace2-1">
                        <table width="100%" border="0">
                            <tr style="text-align: center">
                                <th>Numéro</th>
                                <th>Date</th>
                                <th>Expéditeur</th>
                                <th colspan="2">Sujet</th>
                            </tr>
                            <%
                                String sql = "SELECT mid, date, name, subject FROM message";
                                rs = stmt.executeQuery(sql);
                                while (rs.next()) {
                                    int number = rs.getRow();
                                    int id = Integer.parseInt(rs.getString("mid"));
                                    String date = rs.getString("date");
                                    String sender = rs.getString("name");
                                    String subject = rs.getString("subject");
                            %>
                            <form method="post" action="ReadMessage" name="ReadOrder">
                                <input type="hidden" name="id" value="<%=id%>"/>
                                <tr style="text-align: center">
                                    <td><%= number%></td>
                                    <td><%= date%></td>
                                    <td><%= sender%></td>
                                    <td><%= subject%></td>
                                <form method="post" action="ReadMessage" name="readMss">
                                    <input type="hidden" name="typeMss" value="readMss"/>
                                    <input type="hidden" name="id" value="<%=id%>"/>
                                    <td><input type="submit" value="Lire"/></td>
                                </form>
                                </tr>
                                <% }
                                }%>
                        </table>
                    </div>
                </div>
                <%@include file="sidespace.jsp" %>
            </div>
            <div class="footer"> FOOTER 80*1000 </div>
        </div>
    </body>
    <% } finally {
            out.close();
        }
    %>
</html>

